/**
 * User: yuhao Date: 15-5-14 Time: 下午5:43 UI管理器，负责系统总体的UI调度
 */

define(
    [
        "require",
        "dojo/_base/declare",
        "dojo/_base/lang",
        "dojo/_base/array",
        "dojo/dom",
        "dojo/dom-attr",
        "dojo/dom-class",
        "dojo/dom-style",
        "dojo/_base/html",
        "dojo/window",
        "dojo/on",
        "dojo/fx",
        "dojo/query",
        "dojo/topic",
        "dojo/_base/fx",
        "dojo/date/locale",
        "esri/symbols/PictureMarkerSymbol",
        "esri/renderers/ClassBreaksRenderer",
        "esri/layers/ArcGISDynamicMapServiceLayer",
        "esri/layers/FeatureLayer",
        "dojo/dom-construct",
        "./Map/Map",
        "../gistech/util/utils",
        "../gistech/util/ajaxUtil",
        "dijit/layout/ContentPane",
        "../gistech/widgets/Message/Message",
        "../gistech/widgets/ShowMessage/ShowMessage",
        "../gistech/widgets/ZoomBar/ZoomBar",
        "../gistech/widgets/ArrowWidget/ArrowWidget",
        "../gistech/widgets/ToolBox/ToolBox",
        "../gistech/widgets/menubarWidget/MenuBarWidget",
        "../gistech/widgets/rightWidget/RightWidget",
        "../gistech/widgets/leftWidget/LeftWidget",
        "../gistech/widgets/FeatureQueryWidget/FeatureQueryWidget",
        "../gistech/widgets/UserSet/UserSet",
        "../gistech/widgets/MapLayerResourceWidget/MapLayerResourceWidget",
        "../gistech/widgets/CityResourceWidget/CityResourceWidget",
        "../gistech/widgets/PassWordWidget/PassWordWidget","gistech/util/CityDistCenters","esri/dijit/Print",
        "esri/tasks/PrintTask",
        "esri/tasks/PrintParameters",
        "esri/tasks/PrintTemplate", 
        "../gistech/widgets/bookMark/BookMark"
 
    ],
    function (require, declare, lang, array, dom, domAttr, domClass, 
    		domStyle, html, win, on,dojofx, query, topic,fx,locale,PictureMarkerSymbol,
    		ClassBreaksRenderer,ArcGISDynamicMapServiceLayer,FeatureLayer,domConstruct,Map, utils,ajaxUtil,ContentPane,Message,ShowMessage,
    		ZoomBar,ArrowWidget,ToolBox,MenuBarWidget,RightWidget,LeftWidget,FeatureQueryWidget,UserSet,MapLayerResourceWidget,CityResourceWidget,PassWordWidget
    		,CityDistCenters,Print,PrintTask,PrintParameters,PrintTemplate,BookMark) {

    	/**
		 * ioc.map.userInfoData.isManager 是否为管理员
		 * 
		 * 
		 */
    	var instance = null, clazz;
        clazz = declare(null, {
        	messageArray:null,
            constructor:function (args) {
            	Global.widgets = {};// 引用的组件
                this.map=null;
                this.sysManageMenu = false;
                ioc.map.graphiclayers = new Array();
            },

            /**
			 * 初始化系统UI
			 */
            init:function () {
            	// 初始化要预先查询的内容---后面优化做
            	// var initQueryContext = new InitQueryContext();
            	// initQueryContext.startup();
                this.startMonitor();
                // 初始化容器
                var box = win.getBox(),
                wrapper = dom.byId("wrapper");
                domStyle.set(wrapper, "width", box.w + "px");
                domStyle.set(wrapper, "height", box.h + "px");
                this.initCityDistinctData();// 聚合用到城市行政区的中心点集合
                this.loadMap();
                this.getMessage();
//                this.addEvent();
            },
            /**
			 * 开始监听消息
			 */
            addEvent:function(){
            	on(dojo.query("li a.messageA"),"click",lang.hitch(this,function(e){
            		this.showMessageDetial(e.currentTarget.id);
            	}))
             },
            showMessageDetial:function(id){
            	$.get("../client/backgroundManagement/MessageController/getMessageById",{id:id},function(res){
//            		debugger
            		var messageShowDialog;
            		if(res=="null"){
            			messageShowDialog=new ShowMessage(null);
            		}else{
            			messageShowDialog=new ShowMessage(res);
            		}
            		messageShowDialog.setTitle("消息查看");
            		messageShowDialog.startup();
            	})
            },
            getMessage:function(msg){
//            	debugger
            	var self=this;
            	dojo.empty(dojo.byId("messUl"));
            	
            	   $.getJSON("../client/backgroundManagement/MessageController/allShowMessage",lang.hitch(this,function(res){
//                		debugger
                		var length=res.length;
                		if(length==1&&res[0].title=="暂无通知"){
                			var litag=dojo.create("li");
                			var atag=dojo.create("a",{class:"messageA",innerHTML:res[0].title,style:{textAlign: "center",lineHeight: "auto"}});
                			domConstruct.place(atag,litag);
                			domConstruct.place(litag,dojo.byId("messUl"));
                			$("#breakingnews2").BreakingNews();
                			$(atag).bind("click",lang.hitch(this,function(e){
                				this.showMessageDetial();
                			}));
                		}else{
                			dojo.forEach(res,lang.hitch(this,function(item,index){
                    			var litag=dojo.create("li",{style:{display:"block"}});
                    			var atag=dojo.create("a",{class:"messageA", id:item.id,innerHTML:item.title.slice(0,10)+"...",style:{textAlign: "center",lineHeight: "auto", height: "24px"}})
                    			$(atag).bind("click",lang.hitch(this,function(e){
                    				this.showMessageDetial(e.currentTarget.id);
                    			}));
                    			domConstruct.place(atag,litag);
                    			domConstruct.place(litag,dojo.byId("messUl"));
                    			if(index==length-1&&msg!='refresh'){
                    				$("#breakingnews2").BreakingNews();
                    			};}))
                		}}));	
            },
            startMonitor:function () {
                topic.subscribe("mapLoaded", lang.hitch(this, this.handleMapLoaded));
                topic.subscribe("RefreshMessageBox",lang.hitch(this,this.getMessage));	
                on(window, "resize", function () {
                    topic.publish("windowResize");
                });
                on(document.body, "click", function (e) {
                    topic.publish("bodyClick", e);
                });
                on(document.body, "keyup", function (e) {
                    topic.publish("bodyKeyup", e);
                });
                on(dojo.byId("username"),"click",function(e){
                	if(this.sysManageMenu){
                		dojofx.wipeOut({node: "sysmanagemenu"}).play();
    					this.sysManageMenu = false;
    				}
    			    else{// 列表已显示，则收起列表
    			    	dojofx.wipeIn({node: "sysmanagemenu"}).play();
    					this.sysManageMenu = true;
    				}
                });
                on(dojo.byId("sysmanagepage"),"click",function(e){
// var userSet = new
// UserSet({pos:{l:Math.ceil(document.body.clientWidth)/2-419,t:110}},dojo.byId("dialog"));
// userSet.setTitle("人员维护");
// userSet.startup();
                	window.open( ioc.map.platformManagerUrl);
                });
                  // 现在注释掉
// on(dojo.byId("updatePwd"),"click",function(e){
// var organizationWidget = new
// PassWordWidget({pos:{l:Math.ceil(document.body.clientWidth)/2-419,t:110}},dojo.byId("PassWordWidget"));
// organizationWidget.setTitle("修改密码");
// organizationWidget.startup();
// });
                
                 on(dojo.byId("help"), "click", this.help);
                 on(dojo.byId("message"),"click",this.message);
                  
                
    		    // 退出
    	        on(dojo.byId("quiteout"),"click",function(e){
            		ajaxUtil.request("../client/service/loginController/quiteout","",lang.hitch(this,function(result){
            			if(result.success){
                    		location.href="../login.jsp"; 
                       	}else{
                    		location.href="../login.jsp";   
                    	}
                 	}),function(){
                 		console.error("退出失败！");
                 	});
    	        });
            },
            
            help:function(){
            	window.open("../client/gistech/widgets/Help/help.html");
            },
            message:function(){
            	var messageCreateDialog=new Message();
            	messageCreateDialog.setTitle("消息发布");
            	messageCreateDialog.startup();
            },
            print2:function(){
            	alert(2)
                var printTask = new PrintTask("http://10.1.10.230:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task");
                var template = new PrintTemplate();
                var dpi =  96 ;
                template.exportOptions = {
                    width: 800,
                    height: 600,
                    dpi: Number(dpi)
                };
                template.format = "JPG";
                template.layout = "MAP_ONLY";
                template.preserveScale = false;
                var params = new PrintParameters();
                params.map = ioc.baseMap;
                params.template = template;
                printTask.execute(params, function(evt){
                    window.open(evt.url,"_blank");
                });
            },
            /**
			 * 地图加载完毕的回调
			 * 
			 * @param map
			 */
            handleMapLoaded:function (args) {
            	this.map=args.map;
                this.loadWidgets();      
                this.initUserPrivilege();
                dojo.byId('username').innerText=ioc.map.userInfoData.DISPLAYNAME;
                // this._fullDisplayCountyBySetMapExtent();//设置地图范围使得区界完全显示
                
                
                // 打印"printMap"
// ioc.map.printer = new Print({
// map: this.map,
// url:
// "http://10.1.10.230:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task",
// templates: [{
// label: "Map",
// format: "JPG",
// layout: "MAP_ONLY",
// exportOptions: {
// width: 1700,
// height: 890 ,dpi: 85
//          				
// }
// } ]
// }, dom.byId("printMap"));
// ioc.map.printer.startup();
// ioc.baseMap = this.map;
                  
            },
            /** 设置地图的初始化显示范围，默认完成显示出区界 */
            _fullDisplayCountyBySetMapExtent:function(){
            	 require(["gistech/util/mercatorUtil","esri/geometry/Extent","esri/SpatialReference"], lang.hitch(this,function (mercatorUtil,Extent,SpatialReference){
                 	var extent = this.map.getLayer("hzqj").fullExtent;
                 	this.map.setExtent(extent);
                 	var xmin_proj=mercatorUtil.mercator_latlng_x(extent.xmin);
                 	var ymin_proj=mercatorUtil.mercator_latlng_y(extent.ymin);
                 	var xmax_proj=mercatorUtil.mercator_latlng_x(extent.xmax);
                 	var ymax_proj=mercatorUtil.mercator_latlng_y(extent.ymax);
                 	extent=extent.update(xmin_proj, ymin_proj, xmax_proj, ymax_proj, new SpatialReference({wkid:102100}))
         		 	this.map.setExtent(extent,true);
         	    }));
            },
            /**
			 * 初始化权限
			 */
            initUserPrivilege:function(){
            	// debugger
            	var roleNames = ioc.map.userRoleArea;
            	// 通过类型来判断是否为管理员
            	if(ioc.map.userInfoData.USERTYPE=='0'){
            		roleNames="管理员";
            	}
            	 
            	var roleArr = null;
            	var flag = false ; 
            	if( roleNames!=null){
            		 var roleNameArr = roleNames.split(",");
            		 roleArr = new Array();
            		 for(var i =0;i<roleNameArr.length ;i++){
            			 var roleName = roleNameArr[i];
            			 roleArr.push(roleName);
            			 
            			 if("管理员" == roleName || "投资发展中心" == roleName ){
            				 flag = true ; 
            				 ioc.map.userInfoData.isManager	= true;
                		 } 
            		 }
            		 // 去重
            		    roleArr.sort();
            			var re=[roleArr[0]];
            			for(var i = 1; i< roleArr.length; i++)
            			{
            				if( roleArr[i] !== re[re.length-1])
            				{
            					re.push(roleArr[i]);
            				}
            			}
            			ioc.map.userRoleData = re ;
            			if(!flag){ // 非管理员
            				// 运维
            				/*dojo.query(".yunwei").style('display','none');*/
            				dojo.byId('sysmanagepage').style.display='none';
            				dojo.byId('yunwei').style.display='none';
            				// dojo.byId("organizationManagePage").style.display='none';
            				
            				// 报表
            				// Global.widgets.menubar.staticReport.style.display='none';
            				// Global.widgets.menubar.themeDataStaticReport.style.display='none';
            				
// if(ioc.map.companyName=='null'){
// //聚合中的项目状态 集团负责人可查看
// dojo.byId('projStat').style.display='none';
// }
            			
            			}
            	}
            	
            	// 配置服务资源
            	try{
            		this.initServerInfoUrl();
            	}catch(e){
            		console.log(e)
            	}
            	
            	topic.publish("initUserPrivilegeDone");
            },
            
            /**
			 * 配置服务资源
			 * 
			 */
            initServerInfoUrl : function(){
            	var t = $.parseJSON(ioc.map.userRoleModule)

             
            	for(var i=0;i<t.length;i++){
            		var MODEL_NAME = t[i].MODEL_NAME;
            		if(MODEL_NAME!='全局配置')continue; // 全局配置
            	    var t1 = t[i].LAYERPARAM;
            	    if(t1=="未纳入三旧的村"){
//            	    	debugger
            	    	alert(t1)
            	    }
            	    var tableName = t[i].TABLE_NAME;
                    var dynamicsUrl = t[i].DYNAMICS_URL;
    		        var urlIndex = t[i].LAYER_INDEX; 
    		       
    		        var queryFild = "";
    		        var queryFildValue = "";
    		        var areaField = "";
    		        
    		        var fields = t[i].FIELDS ;
    		        if(fields!=""&&fields!=undefined){
    		        	var fieldArr = fields.split(";");
    		        	for(var g=0;g<fieldArr.length;g++){
    		        		var field = fieldArr[g].split(":");
    		        		if(field[1]!='null'){
    		        			if(field[0]=='AreaField'){
    		        				areaField = field[1].replace('%','').replace('%','');
    		        			}else if(field[0]=='GJQFField'){
    		        				queryFild = field[1].replace('%','').replace('%','');
    		        			}else if(field[0]=='GJQFValue'){
    		        				queryFildValue = field[1].replace('%','').replace('%','');
    		        			}
    		        		}
    		        	}
    		        	
    		        }
    		        
            	    if(t1=='纳入三旧的旧厂'){
            	    	mapinfoTemplate.JCFFL3.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JCFFL3.tableName=tableName;
            	    	mapinfoTemplate.JCFFL3.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JCFFL3.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.JCFFL3.queryFild=queryFild;
            			mapinfoTemplate.JCFFL3.queryFildValue=queryFildValue;
            			mapinfoTemplate.JCFFL3.areaField=areaField;
            	    }else if(t1=='纳入三旧的集体旧厂'){
            	    	mapinfoTemplate.JCFFL3.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JCFFL3.tableName=tableName;
            	    	mapinfoTemplate.JCFFL3.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JCFFL3.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.JCFFL3.jt_queryFild=queryFild; // 过滤条件与旧厂不同
            			mapinfoTemplate.JCFFL3.jt_queryFildValue=queryFildValue;// 过滤条件与旧厂不同
            			mapinfoTemplate.JCFFL3.jt_areaField=areaField;// 过滤条件与旧厂不同
            	    }else if(t1=='纳入三旧的旧城'){
            	    	mapinfoTemplate.JCHFL3.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JCHFL3.tableName=tableName;
            	    	mapinfoTemplate.JCHFL3.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JCHFL3.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.JCHFL3.queryFild=queryFild;
            			mapinfoTemplate.JCHFL3.queryFildValue=queryFildValue;
            			mapinfoTemplate.JCHFL3.areaField=areaField;
            	    }else if(t1=='国有储备用地'){ // 
            	    	mapinfoTemplate.JHGD.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JHGD.tableName=tableName
            	    	mapinfoTemplate.JHGD.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JHGD.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.JHGD.queryFild=queryFild;
            			mapinfoTemplate.JHGD.queryFildValue=queryFildValue;
            			mapinfoTemplate.JHGD.areaField=areaField;
            	    }else if(t1=='未纳入三旧的村'){  // 
            	    	mapinfoTemplate.JCUFL3.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JCUFL3.tableName=tableName
            	    	mapinfoTemplate.JCUFL3.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JCUFL3.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.JCUFL3.queryFild=jt_queryFild;
            			mapinfoTemplate.JCUFL3.queryFildValue=jt_queryFildValue;
            			mapinfoTemplate.JCUFL3.areaField=jt_areaField;
            	    }else if(t1=='纳入三旧的旧村'){
            	    	mapinfoTemplate.JCUFL3.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JCUFL3.tableName=tableName;
            	    	mapinfoTemplate.JCUFL3.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JCUFL3.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.JCUFL3.queryFild=queryFild;
            			mapinfoTemplate.JCUFL3.queryFildValue=queryFildValue;
            			mapinfoTemplate.JCUFL3.areaField=areaField;
            	    }else if(t1=='地铁线路'){
            	    	mapinfoTemplate.GDJTL.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.GDJTL.tableName=tableName;
            	    	mapinfoTemplate.GDJTL.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.GDJTL.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.GDJTL.queryFild=queryFild;
            			mapinfoTemplate.GDJTL.queryFildValue=queryFildValue;
            			mapinfoTemplate.GDJTL.areaField=areaField;
            	    }else if(t1=='地铁站点'){
            	    	mapinfoTemplate.GDJTP.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.GDJTP.tableName=tableName;
            	    	mapinfoTemplate.GDJTP.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.GDJTP.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.GDJTP.queryFild=queryFild;
            			mapinfoTemplate.GDJTP.queryFildValue=queryFildValue;
            			mapinfoTemplate.GDJTP.areaField=areaField;
            	    }else if(t1=='高速公路'){
            	    	mapinfoTemplate.HighWay.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.HighWay.tableName=tableName;
            	    	mapinfoTemplate.HighWay.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.HighWay.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.HighWay.queryFild=queryFild;
            			mapinfoTemplate.HighWay.queryFildValue=queryFildValue;
            			mapinfoTemplate.HighWay.areaField=areaField;
            	    }else if(t1=='高速出入口'){
            	    	mapinfoTemplate.HighWaySite.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.HighWaySite.tableName=tableName;
            	    	mapinfoTemplate.HighWaySite.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.HighWaySite.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.HighWaySite.queryFild=queryFild;
            			mapinfoTemplate.HighWaySite.queryFildValue=queryFildValue;
            			mapinfoTemplate.HighWaySite.areaField=areaField;
            	    }else if(t1=='村自留地'){  
            	    	mapinfoTemplate.LYD.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.LYD.tableName=tableName;
            	    	mapinfoTemplate.LYD.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.LYD.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.LYD.queryFild=queryFild;
            			mapinfoTemplate.LYD.queryFildValue=queryFildValue;
            			mapinfoTemplate.LYD.areaField=areaField;
            	    }else if(t1=='控规'){ 
            	    	mapinfoTemplate.KG.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.KG.tableName=tableName;
            	    	mapinfoTemplate.KG.maplayerinfo.url=dynamicsUrl;
            	    	mapinfoTemplate.KG.maplayerinfo.urlD=dynamicsUrl;
            			mapinfoTemplate.KG.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.KG.queryFild=queryFild;
            			mapinfoTemplate.KG.queryFildValue=queryFildValue;
            			mapinfoTemplate.KG.areaField=areaField;
            	    }else if(t1=='土规'){ 
            	    	mapinfoTemplate.TG.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.TG.tableName=tableName;
            	    	mapinfoTemplate.TG.maplayerinfo.url=dynamicsUrl;
            	    	mapinfoTemplate.TG.maplayerinfo.urlD=dynamicsUrl;
            			mapinfoTemplate.TG.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.TG.queryFild=queryFild;
            			mapinfoTemplate.TG.queryFildValue=queryFildValue;
            			mapinfoTemplate.TG.areaField=areaField;
            	    } else if(t1=='计划供地'){ // 即国有储备用地
            	    	mapinfoTemplate.JHGD.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JHGD.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JHGD.maplayerinfo.sublyidx=urlIndex
            			mapinfoTemplate.JHGD.tableName=tableName;
            			mapinfoTemplate.JHGD.queryFild=queryFild;
            			mapinfoTemplate.JHGD.queryFildValue=queryFildValue;
            			mapinfoTemplate.JHGD.areaField=areaField;
            	    }else if(t1=='招拍挂'){ 
            	    	mapinfoTemplate.ZPG.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.ZPG.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.ZPG.maplayerinfo.sublyidx=urlIndex
            			mapinfoTemplate.ZPG.tableName=tableName;
            			mapinfoTemplate.ZPG.queryFild=queryFild;
            			mapinfoTemplate.ZPG.queryFildValue=queryFildValue;
            			mapinfoTemplate.ZPG.areaField=areaField;
            	    }else if(t1=='未开发用地'){
            	    	mapinfoTemplate.WKF.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.WKF.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.WKF.maplayerinfo.sublyidx=urlIndex
            			mapinfoTemplate.WKF.tableName=tableName;
            			mapinfoTemplate.WKF.queryFild=queryFild;
            			mapinfoTemplate.WKF.queryFildValue=queryFildValue;
            			mapinfoTemplate.WKF.areaField=areaField;
            	    }else if(t1=='国有土地'){ 
            	    	mapinfoTemplate.GYTD.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.GYTD.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.GYTD.maplayerinfo.sublyidx=urlIndex
            			mapinfoTemplate.GYTD.tableName=tableName;
            			mapinfoTemplate.GYTD.queryFild=queryFild;
            			mapinfoTemplate.GYTD.queryFildValue=queryFildValue;
            			mapinfoTemplate.GYTD.areaField=areaField;
            	    }else if(t1=='集体用地'){ 
            	    	mapinfoTemplate.JTYD.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.JTYD.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.JTYD.maplayerinfo.sublyidx=urlIndex
            			mapinfoTemplate.JTYD.tableName=tableName;
            			mapinfoTemplate.JTYD.queryFild=queryFild;
            			mapinfoTemplate.JTYD.queryFildValue=queryFildValue;
            			mapinfoTemplate.JTYD.areaField=areaField;
            	    }else if(t1=='短期项目'){ 
            	    	mapinfoTemplate.DQXM.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.DQXM.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.DQXM.maplayerinfo.sublyidx=urlIndex
            			mapinfoTemplate.DQXM.tableName=tableName;
            			mapinfoTemplate.DQXM.queryFild=queryFild;
            			mapinfoTemplate.DQXM.queryFildValue=queryFildValue;
            			mapinfoTemplate.DQXM.areaField=areaField;
            			mapinfoTemplate.DQXM.layerDisplayName = t1;
            	    }else if(t1=='中长期项目'){ 
            	    	mapinfoTemplate.ZCQXM.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX;
            	    	mapinfoTemplate.ZCQXM.maplayerinfo.url=dynamicsUrl;
            			mapinfoTemplate.ZCQXM.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.ZCQXM.tableName=tableName;
            			mapinfoTemplate.ZCQXM.queryFild=queryFild;
            			mapinfoTemplate.ZCQXM.queryFildValue=queryFildValue;
            			mapinfoTemplate.ZCQXM.areaField=areaField;
            			mapinfoTemplate.ZCQXM.layerDisplayName = t1;
            	    }else if(t1=='外业拓展'){ 
            	    	mapinfoTemplate.LandFeatureLayer.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.LandFeatureLayer.maplayerinfo.url=dynamicsUrl;
            	    	mapinfoTemplate.LandFeatureLayer.tableName=tableName;
            			mapinfoTemplate.LandFeatureLayer.maplayerinfo.sublyidx=urlIndex;
            			mapinfoTemplate.LandFeatureLayer.queryFild=queryFild;
            			mapinfoTemplate.LandFeatureLayer.queryFildValue=queryFildValue;
            			mapinfoTemplate.LandFeatureLayer.areaField=areaField;
                		mapinfoTemplate.LandFeatureLayer.layerDisplayName = t1;
                	    }else if(t1=='在售及未售项目'){ 
                	    	mapinfoTemplate.ZSJWSXM.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
                	    	mapinfoTemplate.ZSJWSXM.maplayerinfo.url=dynamicsUrl;
                			mapinfoTemplate.ZSJWSXM.maplayerinfo.sublyidx=urlIndex
                			mapinfoTemplate.ZSJWSXM.tableName=tableName;
                			mapinfoTemplate.ZSJWSXM.queryFild=queryFild;
                			mapinfoTemplate.ZSJWSXM.queryFildValue=queryFildValue;
                			mapinfoTemplate.ZSJWSXM.areaField=areaField;
                			mapinfoTemplate.ZSJWSXM.layerDisplayName = t1;
                	        
 
            	    }else if(t1=='市界'){ 
            	    	mapinfoTemplate.SJJX.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.SJJX.maplayerinfo.url=dynamicsUrl;
            	    	mapinfoTemplate.SJJX.tableName=tableName;
            	    	mapinfoTemplate.SJJX.maplayerinfo.sublyidx=urlIndex
            	    	mapinfoTemplate.SJJX.queryFild=queryFild;
            	    	mapinfoTemplate.SJJX.queryFildValue=queryFildValue;
            	    	mapinfoTemplate.SJJX.areaField=areaField;
            	    	mapinfoTemplate.SJJX.layerDisplayName = t1;
            	    }else if(t1=='区界'){ 
            	    	mapinfoTemplate.HZQJ.layerurl=t[i].FEATURE_URL+'/'+t[i].LAYER_INDEX
            	    	mapinfoTemplate.HZQJ.maplayerinfo.url=dynamicsUrl;
            	    	mapinfoTemplate.HZQJ.tableName=tableName;
            			mapinfoTemplate.HZQJ.maplayerinfo.sublyidx=urlIndex
            			mapinfoTemplate.HZQJ.queryFild=queryFild;
            			mapinfoTemplate.HZQJ.queryFildValue=queryFildValue;
            			mapinfoTemplate.HZQJ.areaField=areaField;
            			mapinfoTemplate.HZQJ.layerDisplayName = t1;
            	    }            
       

            	}
            },
            
            
            /**
			 * 加载地图并初始化widgets
			 */
            loadMap:function () {
                var mapWidget = new Map({
                    mapId:"map",
                });
                // Global.widgets["map"] = mapWidget;
                mapWidget.startup();
            },
            /**
			 * 加载组件
			 */
            loadWidgets:function (){
            	/* 菜单栏 */
            	var menubarwidget = new MenuBarWidget({map:this.map},dojo.byId("menubarDiv"));
            	menubarwidget.startup();
            	Global.widgets["menubar"]=menubarwidget;
            	
            	/* 左侧导航栏 */
            	var leftWidget = new LeftWidget({},dojo.byId("leftTabCon"));
            	leftWidget.startup();
            	this.initLeftWidget();
            	Global.widgets["left"]=leftWidget;
            	
            	/* 右侧导航栏 */
            	var rightWidget = new RightWidget({},dojo.byId("rightTabCon"));
            	rightWidget.startup();
            	Global.widgets["right"]=rightWidget;
            	
            	/* 搜索框 */
            	var querybarwidget = new FeatureQueryWidget({},dojo.byId("querybar"));
            	querybarwidget.startup();
            	Global.widgets["querybar"]=querybarwidget;
            	
                /* 放大缩小组件 */
                var zoombar=ZoomBar({
                	map:this.map
                });
                
                zoombar.placeAt(dojo.body());
                zoombar.startup();
                Global.widgets["zoombar"] = zoombar;
                
                /* 右下角工具条arr */
                var bottomArrow2=new ArrowWidget({
                    right:'15px',
                    bottom:'105px',
                    expandState:'top',
                    eventName:'toggleToolBox',
                    id:"bottomArrow2",
                    map:this.map
                });
                bottomArrow2.startup();
                bottomArrow2.placeAt(dojo.body());
                Global.widgets["BottomArrow2"]=bottomArrow2;
            },
            
            initLeftWidget:function(){
            	
            	var lefttabCon = dijit.byId("leftTabCon");
            	var ResourceTab = new  ContentPane();
            	var CityTab = new  ContentPane();
            	ResourceTab.set('content', "<div id='ResourceTab' ></div>");
            	CityTab.set('content', "<div id='CityTab' ></div>");
            	lefttabCon.addTab(ResourceTab,"资源列表",false);
            	lefttabCon.addTab(CityTab,"城市列表",false);
            	
            	var mapLayerResourceWidget = new MapLayerResourceWidget({map:this.map,lefttabCon:this.lefttabCon},dojo.byId("ResourceTab"));
            	mapLayerResourceWidget.startup();
            	var cityResourceWidget = new CityResourceWidget({map:this.map,lefttabCon:this.lefttabCon},dojo.byId("CityTab"));
            	cityResourceWidget.startup();
            	lefttabCon.selectTab(ResourceTab);
            	
            	// set tab css
            	$('.dijitTabListWrapper >div',lefttabCon.domNode).css("width","inherit");
            	$('.dijitTabListWrapper >div>:nth-child(1)',lefttabCon.domNode).css({"width":"50%","float":"left"});
            	$('.dijitTabListWrapper >div>:nth-child(2)',lefttabCon.domNode).css({"width":"50%"});
            },
            
            // 初始化城市区中心点
            initCityDistinctData:function(){
            	var g  = new CityDistCenters();
            }
            
        });
        clazz.getInstance = function (args) {
            if (instance === null) {
                instance = new clazz(args);
            }
            return instance;
        };
        return clazz;
    });